package com.sam.im.heiqun.uis.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.sam.im.heiqun.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Martin on 2017/1/11.
 */

public class RedPackageDetailsListAdapter extends BaseAdapter {

    private List<String> data;
    private LayoutInflater inflater;

    public RedPackageDetailsListAdapter(List<String> data, Context context) {
        if (data == null)
            data = new ArrayList<>();
        this.data = data;
        this.inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder ;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.item_receive_red_package_people,parent,false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }


        return convertView;
    }

    private class ViewHolder {

        ImageView headImg;
        TextView nickName;
        TextView receiveTime;
        TextView receiveMoney;

        public ViewHolder(View itemView) {
            headImg = (ImageView) itemView.findViewById(R.id.head_img);
            nickName = (TextView) itemView.findViewById(R.id.nick_name);
            receiveTime = (TextView) itemView.findViewById(R.id.receive_time);
            receiveMoney = (TextView) itemView.findViewById(R.id.receive_money);
        }
    }
}
